﻿using System;
using System.Collections.Generic;
using System.Text;
using Prism.Mvvm;
using Prism.Events;
using UsingEventAggregator.Core;



namespace DataDefine
{
    public class RunParameter : BindableBase
    {
        private string _ParameterName = "";
        public string ParameterName
        {
            get { return _ParameterName; }
            set { SetProperty(ref _ParameterName, value); }
        }

        private decimal _Value;
        public decimal Value
        {
            get { return _Value; }
            set
            {
                SetProperty(ref _Value, value);

                SFMParameterIsChangeEvent.Count++;
                if (ea != null)
                {
                    ea.GetEvent<SFMParameterIsChangeEvent>().Publish(value);
                }

            }
        }
        private decimal _Min;
        public decimal Min
        {
            get { return _Min; }
            set { SetProperty(ref _Min, value); }
        }

        private decimal _Max;
        public decimal Max
        {
            get { return _Max; }
            set { SetProperty(ref _Max, value); }
        }

        private decimal _Default;
        public decimal Default
        {
            get { return _Default; }
            set { SetProperty(ref _Default, value); }
        }

        private string _Unit = "";
        public string Unit
        {
            get { return _Unit; }
            set { SetProperty(ref _Unit, value); }
        }

        private AccessLv _ReadAccessLv;
        public AccessLv ReadAccessLv
        {
            get { return _ReadAccessLv; }
            set { SetProperty(ref _ReadAccessLv, value); }
        }

        private AccessLv _WriteAccessLv;
        public AccessLv WriteAccessLv
        {
            get { return _WriteAccessLv; }
            set { SetProperty(ref _WriteAccessLv, value); }
        }

        private VRWType _ReadWriteType;
        public VRWType ReadWriteType
        {
            get { return _ReadWriteType; }
            set { SetProperty(ref _ReadWriteType, value); }
        }

        private VType _Type;
        public VType Type
        {
            get { return _Type; }
            set { SetProperty(ref _Type, value); }
        }

        public static IEventAggregator ea;

        private int _Address = -1;
        /// <summary>
        /// 按照上位机协议解析的地址
        /// 0-255
        /// </summary>
        public int Address
        {
            get { return _Address; }
            set { SetProperty(ref _Address, value); }
        }

        /// <summary>
        /// 按照上位机协议解析读时的功能码
        /// 2 7
        /// </summary>
        private byte _ReadFcCode;
        public byte ReadFcCode
        {
            get { return _ReadFcCode; }
            set { SetProperty(ref _ReadFcCode, value); }
        }

        //public static Dictionary<(byte Addr, byte Fc), int> ParametersIndexDic = new Dictionary<(byte Addr, byte Fc), int>();


    }

}
